package day09;

import java.io.*;

public class StreamBuffer {

    public static void main(String[] args) {

        File srcFile = new File("src/test11/EaRfXFPUYAEGtmk.jpg");
        File dirFile = new File("src/test11/EEE_COPy.jpg");

        InputStream is = null;
        InputStream bis = null;

        OutputStream os = null;
        OutputStream bos = null;
        try {
            // 字节流
            is = new FileInputStream(srcFile);
            os = new FileOutputStream(dirFile);

            // 写入缓冲流
            bis = new BufferedInputStream(is);
            bos = new BufferedOutputStream(os);
            int l;
            while ((l = bis.read()) != -1) {
                bos.write(l);
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (bis != null) {
                try {
                    bis.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if (bos != null) {
                try {
                    bos.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }

}
